package com.mooco.dongba.sys.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysUserRoleDao {
    @Select("select role_id from sys_user_roles where user_id=#{userId}")
    List<Integer> findRoleIdsByUserId(Integer userId);

    @Delete("delete from sys_user_roles where role_id=#{roleId}")
    int deleteObjectByRoleId(Long roleId);

    @Delete("delete from sys_user_roles where user_id=#{userId}")
    int deleteObjectByUserId(Integer userId);

    int insertObjects(
            @Param("userId") Integer userId,
            @Param("roleIds") Integer[] roleIds);
}
